package com.uqpsoftware.uqplist.tasks;

public class Task {
	private String mName;
	private Boolean mCompleted = false;
	private final int mID;
	private final static String SPACER_SYMBOL = "__#___";

	public Task(String reCreateTaskFromString) throws Exception {
		String[] subStrings = reCreateTaskFromString.split(SPACER_SYMBOL);
		if (subStrings.length == 3) {
			mName = subStrings[0];
			mID = Integer.parseInt(subStrings[1]);
			mCompleted = Boolean.parseBoolean(subStrings[2]);
		} else {
			throw new Exception(
					"The string argument to task constructor was not formatted correctly!!!!");
		}

	}

	public Task(String name, int ID) {
		mName = name;
		mID = ID;
	}

	public void setName(String name) {
		mName = name;
	}

	public String getName() {
		return mName;
	}

	public void setCompleted(Boolean completed) {
		mCompleted = completed;
	}

	public int getID() {
		return mID;
	}

	public Boolean isCompleted() {
		return mCompleted;
	}

	@Override
	public String toString() {
		return mName + SPACER_SYMBOL + mID + SPACER_SYMBOL + isCompleted();
	}

}
